module logs
  integer*4 :: logunit
  character(len=256) :: logfile,mystring
end module logs

module param_module
  integer*4          :: istart
  integer*4          :: iend
  integer*4          :: hdf5_ics
end module param_module

module myfiles
  character(len=256) :: paramfile,indir,outdir,icdir,icfile,infile
end module myfiles

module header_vars
  type header_type
     integer*4 :: NumPart_ThisFile(0:5)       = 0
     integer*4 :: NumPart_Total(0:5)          = 0
     integer*4 :: NumPart_Total_HighWord(0:5) = 0
     integer*4 :: NumFilesPerSnapshot         = 0
     integer*4 :: Flag_SFR                    = 0
     integer*4 :: Flag_Cooling                = 0
     integer*4 :: Flag_StellarAge             = 0
     integer*4 :: Flag_Metals                 = 0
     integer*4 :: Flag_Feedback               = 0
     real*8    :: MassTable(0:5)              = 0.0d0            
     real*8    :: Time_GYR                    = 0.0d0
     real*8    :: ExpansionFactor             = 0.0d0
     real*8    :: Redshift                    = 0.0d0
     real*8    :: BoxSize                     = 0.0d0
     real*8    :: Omega0                      = 0.0d0
     real*8    :: OmegaBaryon                 = 0.0d0
     real*8    :: OmegaLambda                 = 0.0d0
     real*8    :: HubbleParam                 = 0.0d0
  end type header_type
  type old_header_type
     integer*4 :: NumPart_ThisFile(0:5)       = 0
     real*8    :: MassTable(0:5)              = 0.0d0            
     real*8    :: Time                        = 0.0d0
     real*8    :: Redshift                    = 0.0d0
     integer*4 :: Flag_SFR                    = 0
     integer*4 :: Flag_Feedback               = 0
     integer*4 :: NumPart_Total(0:5)          = 0
     integer*4 :: Flag_Cooling                = 0
     integer*4 :: NumFilesPerSnapshot         = 0
     real*8    :: BoxSize                     = 0.0d0
     real*8    :: Omega0                      = 0.0d0
     real*8    :: OmegaLambda                 = 0.0d0
     real*8    :: HubbleParam                 = 0.0d0
     integer*4 :: Flag_StellarAge             = 0
     integer*4 :: Flag_Metals                 = 0
     integer*4 :: NumPart_Total_HighWord(0:5) = 0
     character(len=64) :: Padding    
  end type old_header_type
  type(header_type)     :: header
  type(old_header_type) :: binary_ics_header
  integer*4, dimension(0:5) :: NumGathered
end module header_vars

module units_and_constants
  type units_data
     real*8 :: UnitLength_in_cm
     real*8 :: UnitMass_in_g
     real*8 :: UnitVelocity_in_cm_per_s
     real*8 :: UnitDensity_in_cgs
     real*8 :: UnitEnergy_in_cgs
     real*8 :: UnitPressure_in_cgs
     real*8 :: UnitTime_in_s
  end type units_data
  type constants_data
     real*8 :: PI
     real*8 :: GAMMA
     real*8 :: GRAVITY
     real*8 :: SOLAR_MASS
     real*8 :: SOLAR_LUM
     real*8 :: RAD_CONST
     real*8 :: AVOGADRO
     real*8 :: BOLTZMANN
     real*8 :: GAS_CONST
     real*8 :: C
     real*8 :: PLANCK
     real*8 :: CM_PER_MPC
     real*8 :: PROTONMASS
     real*8 :: ELECTRONMASS
     real*8 :: ELECTRONCHARGE
     real*8 :: HUBBLE
     real*8 :: T_CMB0
     real*8 :: SEC_PER_MEGAYEAR
     real*8 :: SEC_PER_YEAR
     real*8 :: STEFAN
     real*8 :: THOMPSON
     real*8 :: EV_TO_ERG
     real*8 :: Z_Solar
  end type constants_data
  type(units_data) :: Units
  type(constants_data) :: Constants
end module units_and_constants


module particle_data
  type real2d_AllSnaps_type
     real*4, allocatable, dimension(:,:) :: Type0
     real*4, allocatable, dimension(:,:) :: Type1
     real*4, allocatable, dimension(:,:) :: Type2
     real*4, allocatable, dimension(:,:) :: Type3
     real*4, allocatable, dimension(:,:) :: Type4
     real*4, allocatable, dimension(:,:) :: Type5
  end type real2d_AllSnaps_type
  type int1d_AllSnaps_type
     integer*4, allocatable, dimension(:) :: Type0
     integer*4, allocatable, dimension(:) :: Type1
     integer*4, allocatable, dimension(:) :: Type2
     integer*4, allocatable, dimension(:) :: Type3
     integer*4, allocatable, dimension(:) :: Type4
     integer*4, allocatable, dimension(:) :: Type5
  end type int1d_AllSnaps_type
  type(int1d_AllSnaps_type)        :: ParticleIDs,IndexIDs
  type(int1d_AllSnaps_type)        :: UniqueIDs,SnapIDs,UniqueSnapIDs
  type(real2d_AllSnaps_type)       :: UniqueCoordinates,UniqueVelocity
  type(real2d_AllSnaps_type)       :: ForceFreeCoordinates

  integer*4, dimension(0:5)              :: NumPart_Total_AllSnaps = 0
  integer*4, dimension(0:5)              :: NumPart_Unique         = 0
  integer*4, dimension(0:5)              :: NumPart_Unique_Final   = 0
  integer*4, allocatable, dimension(:,:) :: SnapOffset
  real*8                    :: HubbleParam_a

  integer*4, dimension(0:5) :: NumSelected
  real*4 :: x0,y0,z0,r0

end module particle_data


module ic_data
  integer*4, dimension(0:5) :: NumPart_ICs
  type IC_real2d
     real*4, allocatable, dimension(:,:) :: Type0
     real*4, allocatable, dimension(:,:) :: Type1
     real*4, allocatable, dimension(:,:) :: Type2
     real*4, allocatable, dimension(:,:) :: Type3
     real*4, allocatable, dimension(:,:) :: Type4
     real*4, allocatable, dimension(:,:) :: Type5
  end type IC_real2d
  type IC_int1d
     integer*4, allocatable, dimension(:) :: Type0
     integer*4, allocatable, dimension(:) :: Type1
     integer*4, allocatable, dimension(:) :: Type2
     integer*4, allocatable, dimension(:) :: Type3
     integer*4, allocatable, dimension(:) :: Type4
     integer*4, allocatable, dimension(:) :: Type5
  end type IC_int1d
  type(IC_real2d) :: IC_Coordinates,IC_Velocity
  type(IC_int1d)  :: IC_ParticleIDs,IC_IndexIDs
end module ic_data
